using System;
using System.Data;
using PCSComProduction.ScrapRecording.DS;
using PCSComProduction.ShopFloorControl.DS;

using PCSComUtils.PCSExc;

namespace PCSComProduction.ShopFloorControl.BO
{
	public class DispatchListByWorkOrderBO //:  IDispatchListByWorkOrderBO
	{
		public DispatchListByWorkOrderBO()
		{
			//
			// TODO: Add constructor logic here
			//
		}
		#region IObjectBO Members
		/// <summary>
		/// - Get Dispatch Detail by Dispatch Master ID retrieve from - Get Dispatch Master data by WorkOrderDetailID
		/// </summary>
		///<author>
		/// Do Manh Tuan
		/// 16-06-2005
		/// </author>
		//[AutoComplete(true)]
		public DataSet GetDispatchData(int pintWorkOrderDetailID)
		{
			try
			{
				dsDispatchDetail = new PRO_DispatchDetailDS();
				return 	dsDispatchDetail.GetDetailDispatchData(pintWorkOrderDetailID);
			}
			catch (PCSDBException ex)
			{
				throw ex;
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		/// <summary>
		/// Call PRO_OperationStatusDS.List and return DataTable
		/// </summary>
		//[AutoComplete(true)]
		public DataTable GetLaborMachineCode()
		{
			try
			{
				PRO_OperationStatusDS dsOperationStatus = new PRO_OperationStatusDS();
				return dsOperationStatus.List().Tables[0];
			}
			catch (PCSDBException ex)
			{
				throw ex;
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		
		/// <summary>
		/// Update detail from DataTable
		/// </summary>
		/// <param name="dtbData"></param>
		//[AutoComplete(true)]
		public void UpdateDataTable(DataTable dtbData)
		{
			try
			{
				DataSet dstData = new DataSet();	
				dstData.Tables.Add(dtbData.Copy());
				dsDispatchDetail = new PRO_DispatchDetailDS();
				dsDispatchDetail.UpdateDataSet(dstData);
			}
			catch (PCSDBException ex)
			{
				throw ex;
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message, ex);
			}

		}

		/// <summary>
		/// Update detail from DataTable
		/// </summary>
		/// <param name="dstData"></param>
		//[AutoComplete(true)]
		public void UpdateDataSet(DataSet dstData)
		{
			try
			{
				dsDispatchDetail = new PRO_DispatchDetailDS();
				dsDispatchDetail.UpdateDataSet(dstData);
			}
			catch (PCSDBException ex)
			{
				throw ex;
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message, ex);
			}

		}

		/// <summary>
		/// Get Object WOScheduleMaster by WOMaster and WODetail
		/// </summary>
		/// <param name="pintWOMasterID"></param>
		/// <param name="pintWODetailID"></param>
		/// <returns></returns>
		/// <author>
		/// Do Manh Tuan
		/// 21-06-2005
		/// </author>
		//[AutoComplete(true)]
		public object GetObjectWOScheduleMaster(int pintWOMasterID, int pintWODetailID)
		{
			try
			{
				return new PRO_WOScheduleMasterDS().GetObjectVO(pintWOMasterID, pintWODetailID);	
			}
			catch (PCSDBException ex)
			{
				throw ex;
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message, ex);
			}

		}

		//[AutoComplete(true)]
		public void Update(object pobjMaster)
		{
			// TODO:  Add DispatchListByWorkOrderBO.Update implementation
		}

		//[AutoComplete(true)]
		public void Delete(object pObjectVO)
		{
			// TODO:  Add DispatchListByWorkOrderBO.Delete implementation
		}

		//[AutoComplete(true)]
		public void Add(object pObjectDetail)
		{
			// TODO:  Add DispatchListByWorkOrderBO.Add implementation
		}

		//[AutoComplete(true)]
		public object GetObjectVO(int pintID, string VOclass)
		{
			// TODO:  Add DispatchListByWorkOrderBO.GetObjectVO implementation
			return null;
		}

		#endregion
		/// <summary>
		/// 1. Update Dispatch Master object
		/// 2. Update detail DataSet
		/// </summary>
		//[AutoComplete(true)]
		public void UpdateDispatchMaster(object pobjMaster, DataSet pdstDetailData)
		{
		}
		private DS.PRO_DispatchMasterDS dsDispatchMaster;
		private DS.PRO_DispatchDetailDS dsDispatchDetail;
	}
}
